<template>
  <footer class="footer" v-show="list.length">
    <span class="todo-count" v-show="remainder"
      ><strong>{{ remainder }}</strong
      >剩余</span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: call === 'all' }"
          @click="handoff('all')"
          href="#/"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: call === 'active' }"
          @click="handoff('active')"
          
          href="#/active"
          >进行中</a
        >
      </li>
      <li>
        <a
          :class="{ selected: call === 'completed' }"
          @click="handoff('completed')"
          href="#/completed"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="purge" v-show="showClear">
      清除已完成
    </button>
  </footer>
</template>
<script>
export default {
  name: 'TodoFooter',
  props: {
    list: {
      type: Array,
      required: true,
    },
    call: {
      type: String,
      required: true,
    },
  },
  methods: {
    purge() {
      this.$emit('purge')
    },
    handoff(value) {
      this.$emit('handoff', value)
    },
  },
  computed: {
    remainder() {
      return this.list.filter((item) => !item.isDone).length
    },
    showClear() {
      return this.list.filter((item) => item.isDone).length
    },
  },
}
</script>
<style lang="less" scoped></style>
